﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblPopupDAO
    {
        private DBService _db = null;
        public TblPopupDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }


        public DataTable InsPopup(TblPopup popup, int mode)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("sp_TblPopup",
                    new string[] { "@ID", "@NoiDung", "@mode" }, new object[] { popup.ID, popup.NoiDung, mode}, CommandType.StoredProcedure); 
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetPopup()
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("Select * from TblPopup", false, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }


        public DataTable GetPopup_ByID(int ID)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("Select * from TblPopup where ID = @ID", 
                    new string[]{ "@ID" }, new object[]{ ID }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }
    }
}
